#include<iostream>
using namespace std;
const int N = 1e6 + 10;
int arr[N];
int n, k;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++) {
		scanf_s("%d", &arr[i]);
	}
	cin >> k;
	for (int i = 1; i <= n; i++) {
		int mi = 1e9;	
		for (int j = i - k; j <= i + k; j++) {
			if (j >= 1 && j <= n) {
				mi = min(arr[j], mi);
			}
		}
		cout << mi << " ";
	}
	return 0;
}